/*    */ package com.hp.bon.sgw.core.processor;
/*    */ 
/*    */ import com.hp.bon.sgw.Constants;
/*    */ import com.hp.bon.sgw.core.CallParam;
/*    */ import com.hp.bon.sgw.core.InprogressMessageQueue;
/*    */ import com.hp.bon.sgw.core.channel.IChannel;
/*    */ import com.hp.bon.sgw.core.channel.handler.IAsynCallHandler;
/*    */ import com.hp.bon.sgw.domain.Node;
/*    */ import com.hp.bon.sgw.service.ConfigService;
/*    */ import com.hp.ocs.diameter.message.AVP;
/*    */ import com.hp.ocs.diameter.message.AVP_OctetString;
/*    */ import com.hp.ocs.diameter.message.Message;
/*    */ import java.util.concurrent.ConcurrentHashMap;
/*    */ import org.slf4j.Logger;
/*    */ 
/*    */ public class OcsSessionCtrlProcessor extends Processor
/*    */ {
/*    */   public int process(CallParam callParam)
/*    */   {
/* 19 */     Message req = (Message)callParam.getRequest();
/*    */ 
/* 21 */     AVP avp = req.find(293);
/* 22 */     int result = 0;
/* 23 */     Node destNode = null;
/* 24 */     if (avp == null) {
/* 25 */       result = 5005;
/*    */     } else {
/* 27 */       String destHost = new AVP_OctetString(avp).queryValueAsString();
/* 28 */       destNode = (Node)ConfigService.name2NodeMap.get(destHost);
/* 29 */       if (destNode == null) {
/* 30 */         result = 3002;
/*    */       }
/* 32 */       else if (destNode.getStatus() != 1) {
/* 33 */         result = 3002;
/*    */       }
/*    */ 
/*    */     }
/*    */ 
/* 38 */     if (result != 0) {
/* 39 */       callParam.setRetCode(result);
/* 40 */       callParam.setResultMsg("no Route for " + callParam.getServiceContextId());
/* 41 */       endProcess(callParam);
/* 42 */       return 0;
/*    */     }
/*    */ 
/* 45 */     callParam.setToNode(destNode);
/* 46 */     Constants.LOG.info("OcsSessionCtrlProcessor messsage to " + destNode.getHostId() + ",sessionId:" + callParam.getSessionId());
/* 47 */     InprogressMessageQueue.getInstance().addRequest(callParam);
/* 48 */     destNode.getChannel().sendRequest(callParam);
/* 49 */     return 0;
/*    */   }
/*    */ 
/*    */   public int endProcess(CallParam callParam)
/*    */   {
/* 54 */     if (Constants.LOG.isDebugEnabled()) {
/* 55 */       Constants.LOG.debug("OcsSessionCtrlProcessor endProcess");
/*    */     }
/* 57 */     callParam.getAsynHandler().onCallResult(callParam);
/* 58 */     return 0;
/*    */   }
/*    */ }

/* Location:           C:\Users\think\Desktop\sgw_2.1.jar
 * Qualified Name:     com.hp.bon.sgw.core.processor.OcsSessionCtrlProcessor
 * JD-Core Version:    0.6.1
 */